<?php
namespace app\modules\content\models;

use yii\db\ActiveRecord;
use yii;

class IeltsWrite extends ActiveRecord
{
    public static function tableName()
    {
        return '{{%ielts_write}}';
    }

    public function rules()
    {
        return [
            // username and password are both required
            // [['pic', 'url'], 'required'],

        ];
    }

    public static function writeData($data){
        foreach ($data as $k=>$v){
            $data[$k]['tag'] = explode(',',$v['tags']);
            $data[$k]['updateTime'] = $v['updateTime']?date('Y/m/d',$v['updateTime']):'';
            $data[$k]['question'] = str_replace("/files/", Yii::$app->params['thinkUrl']."/files/",$v['question']);
            $data[$k]['answer'] = str_replace("/files/", Yii::$app->params['thinkUrl']."/files/",$v['answer']);
            $data[$k]['status'] = IeltsWriteAnswer::isSubmit($v['id']);
        }
        return $data;
    }

}